﻿using System;
using System.Text;

namespace MortgageCalculator.Demo
{
    public interface IMortgageCalculatorInput
    {
        decimal InterestRate { get; set; }
        decimal LoanAmount { get; set; }
        int DurationOfLoan { get; set; }
        DateTime LoanStartDate { get; set; }
        decimal PropertyTax { get; set; }
    }

    public class MortgageCalculatorInput : IMortgageCalculatorInput
    {
        public decimal PurchasePrice { get; set; }
        public decimal InterestRate { get; set; }
        public int DurationOfLoan { get; set; }
        public decimal LoanAmount { get; set; }
        public DateTime LoanStartDate { get; set; }
        public decimal PropertyTax { get; set; }
        public decimal MaxBalanceAtMiddleDuration { get; set; }
        public decimal MaxInterestPaidWarning { get; set; }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Purchase Price: {0}\n", this.PurchasePrice.ToStringCurrency());
            sb.AppendFormat("Interest Rate: {0}\n", this.InterestRate.ToStringPercentage());
            sb.AppendFormat("Duration Of Loan (months): {0}\n", this.DurationOfLoan);
            sb.AppendFormat("Loan Amount: {0}\n", this.LoanAmount.ToStringCurrency());
            sb.AppendFormat("Loan Start Date: {0}\n", this.LoanStartDate.ToShortDateString());
            sb.AppendFormat("Property Tax: {0}\n", this.PropertyTax.ToStringCurrency());
            sb.AppendFormat("MaxBalance At Middle Duration: {0}\n", this.MaxBalanceAtMiddleDuration.ToStringCurrency());
            sb.AppendFormat("Max Interest Paid Warning: {0}\n", this.MaxInterestPaidWarning.ToStringCurrency());

            return sb.ToString();
        }
    }

    public class MaxInterestRateCalculatorInput : IMortgageCalculatorInput
    {
        public decimal InterestRate { get; set; }
        public int DurationOfLoan { get; set; }
        public decimal LoanAmount { get; set; }
        public DateTime LoanStartDate { get; set; }
        public decimal MaxInterestPaid { get; set; }
        public decimal PropertyTax { get; set; }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Interest Rate: {0}\n", this.InterestRate.ToStringPercentage());
            sb.AppendFormat("Duration Of Loan (months): {0}\n", this.DurationOfLoan);
            sb.AppendFormat("Loan Amount: {0}\n", this.LoanAmount.ToStringCurrency());
            sb.AppendFormat("Loan Start Date: {0}\n", this.LoanStartDate.ToShortDateString());
            sb.AppendFormat("Property Tax: {0}\n", this.PropertyTax.ToStringCurrency());
            sb.AppendFormat("Max Interest Paid: {0}\n", this.MaxInterestPaid.ToStringCurrency());
         
            return sb.ToString();
        }
    }
}
